﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using SpringStudio.Common;
using SpringStudio.DAL;

namespace Sdepci.InfoCode.BLL.CodeDesign
{
    /// <summary>
    /// 编码信息简要表
    /// </summary>
    public class Brief
    {
        #region 属性定义

        private string _briefGuid;
        /// <summary>
        /// 编码编号
        /// </summary>
        public string BriefGuid
        {
            get { return this._briefGuid; }
        }

        private string _briefCode;
        /// <summary>
        /// 信息编码
        /// </summary>
        public string BriefCode
        {
            get { return this._briefCode; }
        }

        private string _briefDesc;
        /// <summary>
        /// 编码说明
        /// </summary>
        public string BriefDesc
        {
            get { return this._briefDesc; }
        }

        private string _ruleGuid;
        /// <summary>
        /// 编码类型编号
        /// </summary>
        public string RuleGuid
        {
            get { return this._ruleGuid; }
        }

        private string _createTime;
        /// <summary>
        /// 创建时间
        /// </summary>
        public string CreateTime
        {
            get { return this._createTime; }
        }

        private string _createUserId;
        /// <summary>
        /// 创建者证档号
        /// </summary>
        public string CreateUserId
        {
            get { return this._createUserId; }
        }

        private string _serialReference;
        /// <summary>
        /// 流水号参考码
        /// </summary>
        public string SerialReference
        {
            get { return this._serialReference; }
        }

        private string _serialNumber;
        /// <summary>
        /// 当前流水号值
        /// </summary>
        public string SerialNumber
        {
            get { return this._serialNumber; }
        }

        #endregion

        #region 构造方法

        public Brief(string briefGuid)
        {
            this._briefGuid = briefGuid;

            try
            {
                string sql = "Select BriefGuid,BriefCode,BriefDesc,RuleGuid,CreateTime,CreateUserId,SerialReference,SerialNumber From InfoCodeBrief Where BriefGuid=@BriefGuid";
                DataSet ds = SqlHelper.ExecuteDataSet(ConnectionString.Default, CommandType.Text, sql,
                    SqlHelper.NewSqlParameter("@BriefGuid", this._briefGuid));
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    this._briefGuid = row["BriefGuid"].ToString();
                    this._briefCode = row["BriefCode"].ToString();
                    this._briefDesc = row["BriefDesc"].ToString();
                    this._ruleGuid = row["RuleGuid"].ToString();
                    this._createTime = row["CreateTime"].ToString();
                    this._createUserId = row["CreateUserId"].ToString();
                    this._serialReference = row["SerialReference"].ToString();
                    this._serialNumber = row["SerialNumber"].ToString();
                }
                else
                {
                    throw new Exception("没有找到该值对应的详细记录！（参数：briefGuid'" + this._briefGuid + "'）");
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.Handle(ex);
            }
        }

        #endregion

    }
}
